function submit() {
    var agree = document.querySelector(".xieyi").querySelector("input").checked;
    if (!agree) {
        document.querySelector(".xieyi").querySelector("span").style.display = "inline";
        return false;
    }
    else {
        document.querySelector(".xieyi").querySelector("span").style.display = "none";
        var tel = document.getElementById("telephone").onblur();
        var pwd = document.getElementById("pwd").onblur();
        var score = document.getElementById("pwd").oninput();
        if (tel && pwd && score) {
            // document.querySelector("form").submit();
            return true;
        }
        else {
            return false;
        }
    }
}

function checkTel() {
    var tel = document.getElementById("telephone");
    var span = tel.parentElement.nextElementSibling;
    if (tel.value) {
        if (tel.value[0] != "1" || tel.value.length != 13) {
            span.className = "wrong";
            span.innerHTML = "手机号格式不正确，请重新输入！";
        }
        else {
            span.className = "right";
            span.innerHTML = "";
            return true;
        }
    }
    else {
        span.className = "wrong";
        span.innerHTML = "请输入手机号！";
    }
}

function checkPwd() {
    var pwd = document.getElementById("pwd");
    var span = pwd.parentElement.nextElementSibling;
    if (pwd.value) {
        if (pwd.value.length < 6) {
            span.className = "wrong";
            span.innerHTML = "密码长度需大于6位！";

        }
        else {
            // pwd.value.indexOf("");
            span.className = "right";
            span.innerHTML = "";
            return true;
        }
    }
    else {
        span.className = "wrong";
        span.innerHTML = "请输入密码！";
    }
}

function safeState() {
    var pwd = document.getElementById("pwd");
    var weak = document.querySelector(".safety").querySelectorAll("p")[0];
    var genaral = document.querySelector(".safety").querySelectorAll("p")[1];
    var strong = document.querySelector(".safety").querySelectorAll("p")[2];
    var score = 0;
    if (pwd.value.length >= 6) {
        score += 1;
    }
    if (pwd.value.length >= 10) {
        score += 2;
    }
    if (pwd.value.indexOf(".") != -1) {
        score += 3;
    }
    // console.log("now-score:" + score);

    // 检测score
    if (score >= 5) {
        score = "strong";
        strong.className = score;
        genaral.className = "";
        weak.className = "";
    }
    if (score >= 3) {
        score = "genaral";
        strong.className = "";
        genaral.className = score;
        weak.className = "";
    }
    if (score >= 0) {
        score = "weak";
        strong.className = "";
        genaral.className = "";
        weak.className = score;
    }
    return score;
}

function checkPwd2() {
    var pwd = document.getElementById("pwd");
    var pwd2 = document.getElementById("pwd2");
    var span = pwd2.parentElement.nextElementSibling;
    if (pwd2.value != pwd.value) {
        span.className = "wrong";
        span.innerHTML = "两次密码不一致！";
    }
    else {
        span.className = "right";
        span.innerHTML = "";
        return true;
    }
}

